﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using MVCToolkit.Attributes;
using MVCToolkit.Controls;
using System.Web.Mvc;
using MVCToolkit.Validations;

namespace MVCToolkitWebExample.Models
{
    public class InputModel
    {
        [Required]
        [Display(Name = "First Name")]
        [Html5Placeholder(Value = "First Name")]
        public string FirstName { get; set; }

        [Display(Name = "Last Name")]
        public string LastName { get; set; }

        [Required]
        [Display(Name = "Password")]
        [Html5Placeholder(Value = "Password")]
        public string Password { get; set; }

        [Required]
        [Display(Name = "Confirm Password")]
        [Html5Placeholder(Value = "Confirm Password")]
        [Comparer("Password", ComparisionOperator.EqualTo, ErrorMessage = "Confirm password do not match with password")]
        public string ConfirmPassword { get; set; }

        [Display(Name = "Gender")]
        public bool? IsMale { get; set; }

        [Display(Name = "I am above 18")]
        public bool IsAbove18 { get; set; }

        [Display(Name = "Passport Number")]
        [RequiredIf("IsAbove18", Comparison.IsEqualTo, true, ErrorMessage = "Passport Number is required if person is above 18")]
        public string PassportNumber { get; set; }

        [Required]
        public int Id { get; set; }

        [Display(Name = "Email")]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                           @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                           @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
                           ErrorMessage = "{0} has invalid email format.")]
        [Html5Placeholder(Value = "Email")]
        public string Email { get; set; }

        [Display(Name = "Age")]
        public int Age { get; set; }

        [Display(Name = "Elder Brother Age")]
        [Comparer("Age", ComparisionOperator.GreaterThanEqualTo)]
        public int ElderBortherAge { get; set; }

        [Display(Name = "Hobbies")]
        public IList<int> Hobbies { get; set; }
        
        public IList<ListItem> HobbyOptions { get; set; }
    }
}